<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // let arr = [1, 2, 3];

        // 赋值符号左右两边结构一致
        // let [a, b, c] = [1, 2, 3];
        // let [, b] = [1, 2, 3];
        // let [, , , x = 0] = [1, 2, 3];

        // console.log(x);


        // let a = 1;
        // let b = 2;
        // let c = 3;



        // let student = { name: '张三', age: 20, gender: '女' };

        // let { name: a, age: b } = student;
        // console.log(a, b);

        // let { name: name, age: age } = student;
        // let { name, age } = student;
        // 解构赋值的默认值
        // let { age, gender = "男" } = student;
        // console.log(gender);


        // let a = 1;
        // let b = 2;

        // [a, b] = [b, a];



        // function foo([a, b, c]) {
        //     console.log(a, b, c);
        // }

        // // function foo(arr) {
        // //     const [a, b, c] = arr;
        // //     console.log(a, b, c);
        // // }
        // foo([1, 2, 3])


        // function bar({ name, age, gender }) {
        //     console.log(name); 
        //     console.log(age); 
        //     console.log(gender); 
        // }


        // bar({ name: "张三", age: 20, gender: '男' });


        // 1. 没有传参时，接收到的参数实际上是undefined 
        // 2. 不能对undefined进行对象或数组的语法解构

        function bar({ name, age, gender } = {}) {
            console.log(name);
            console.log(age);
            console.log(gender);
        }

        bar();


      





    </script>
</body>

</html>